package com.test.ssh.service;

import com.test.ssh.dao.EmployeeDao;
import com.test.ssh.entities.Employee;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author liuziyang
 * @create 2018-10-07 21:46
 */
public class EmployeeService {
    private EmployeeDao employeeDao;

    public void setEmployeeDao(EmployeeDao employeeDao) {
        this.employeeDao = employeeDao;
    }

    public List<Employee> getAll() {
        return employeeDao.getAll();
    }

    public void delete(Integer id) {
        employeeDao.delete(id);
    }

    public void saveOrUpdate(Employee employee) {
        employeeDao.saveOrUpdate(employee);
    }

    public boolean isLastNameIsValid(String lastName) {
        return employeeDao.getEmployeeByLastName(lastName) == null;
    }

    public Employee get(Integer id) {
        return employeeDao.getEmployeeById(id);
    }
}
